﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">
    <html>
      <head>
        <style type="text/css">
          *{font-family:Calibri;}
          h2 {color: sienna}
          p {margin-left: 20px}
          .resultsHdrRow { padding: 5px }
          .resultsRow { padding: 5px }
          .passed {color:green}
          .failed {color:red}
          table { font-family:Calibri; margin: 1em; border-collapse: collapse; }
          td, th { padding: .3em; border: 1px #ccc solid; }
          th{background-color:#eee;}
        </style>
      </head>
      <body>
        <h2>Test Results</h2>
        <h3>Summary</h3>
        <ul>
          <li>
            Total Tests:    <xsl:value-of select="Result/Total"/>
          </li>

          <li>
            Tests passed:   <span class="passed">
              <xsl:value-of select="Result/Pass"/>
            </span>
          </li>
          <li>
            Tests Failed:
            <xsl:if test="Result/Failed > 0">
              <span class="failed">
                <xsl:value-of select="Result/Failed"/>
              </span>
            </xsl:if>

            <xsl:if test="Result/Failed = 0">
              <xsl:value-of select="Result/Failed"/>
            </xsl:if>

          </li>
        </ul>
        <table border="1" width="80%" >
          <tr  class="resultsHdrRow">
            <th align="left">TestCase</th>
            <th align="left">Result</th>
          </tr>
          <xsl:for-each select="Result/TestCase" >

            <xsl:if test="CheckResult='Pass'">
              <tr valign="top" class="resultsRow">
                <td width='93%'>
                  <xsl:value-of select="Desc"/>
                </td>
                <td width='7%' class="passed">
                  <xsl:value-of select="CheckResult"/>
                </td>
              </tr>
            </xsl:if>

            <xsl:if test="CheckResult='Failed'">
              <tr valign="top" class="resultsRow">
                <td width='93%'>
                  <xsl:value-of select="Desc"/>
                </td>
                <td width='7%' class ="failed">
                  <xsl:value-of select="CheckResult"/>
                </td>
              </tr>
            </xsl:if>

          </xsl:for-each>

        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>